<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <title>借款申请管理</title>
    <!-- plugins:css -->
    <link rel="stylesheet" href="../../vendors/iconfonts/mdi/css/materialdesignicons.min.css"/>
    <link rel="stylesheet" href="../../vendors/css/vendor.bundle.base.css"/>
    <link rel="stylesheet" href="../../data/styles.css"/>
    <!-- endinject -->
    <!-- inject:css -->
    <link rel="stylesheet" href="../../css/style.css"/>
    <!-- endinject -->
    <link rel="shortcut icon" href="../../images/favicon.png"/>
    <style type="text/css">
        .table {
            table-layout: auto !important;
            word-break: keep-all !important;
        }

        ::-webkit-scrollbar {
            width: 6px;
            height: 10px;
        }

        ::-webkit-scrollbar-track {
            background-color: rgba(255, 255, 255, 0);
        }

        ::-webkit-scrollbar-thumb {
            background-color: rgba(255, 255, 255, 0);
            transition: background-color .3s;
        }

        ::-webkit-scrollbar-thumb:hover {
            width: 5px;
            background-color: rgba(200, 200, 200, 0.88);
            -webkit-border-radius: 5px;
            transition: background-color .3s;
        }

    </style>
</head>
<body>

<div class="col-12 grid-margin stretch-card">
    <div class="card">
        <div class="card-body" style="overflow: auto">
            <div class="page-header">
                <h5 class="card-title"><i class="mdi mdi-home"></i><span style="vertical-align: inherit"><span
                        style="vertical-align: inherit">首页/贷前管理/借款申请管理</span></span></h5>
            </div>
            <form class="form-inline" th:action="@{/xm/secondCheck}" id="queryForm">
                <input type="hidden" name="currentPageNo" value="1"/>
                <label class="sr-only" for="inlineFormInputName1">姓名</label>
                <input type="text" th:value="${beforeOrderQuery?.queryName}" class="form-control mb-2 mr-sm-2"
                       id="inlineFormInputName1" placeholder="姓名" name="queryName" size="5"/>
                <label class="sr-only" for="inlineFormInputName2">手机号</label>
                <input type="text" th:value="${beforeOrderQuery?.queryPhone}" class="form-control mb-2 mr-sm-2"
                       id="inlineFormInputName2" placeholder="手机号" name="queryPhone" size="5"/>
                <label class="sr-only" for="inlineFormInputName3">贷款类型</label>
                <select id="inlineFormInputName3" placeholder="贷款类型" class="form-control mb-2 mr-sm-2" name="queryType">
                    <option value="0">贷款类型</option>
                    <option th:each="HLoanProducts:${LoanTypes}" th:value="${HLoanProducts.productId}"
                            th:text="${HLoanProducts.loanType}"
                            th:selected="${beforeOrderQuery?.queryType == HLoanProducts.productId}"></option>
                </select>
                <label class="sr-only" for="inlineFormInputName4">订单状态</label>
                <select id="inlineFormInputName4" class="form-control mb-2 mr-sm-2" name="queryBoType">
                    <option value="">订单状态</option>
                    <option value="等待复审" th:selected="${beforeOrderQuery?.queryBoType == '等待复审'}">未处理</option>
                    <option value="复审通过" th:selected="${beforeOrderQuery?.queryBoType == '复审通过'}">已完成</option>
                    <option value="复审拒绝" th:selected="${beforeOrderQuery?.queryBoType == '复审拒绝'}">已拒绝</option>
                </select>
                <input type="date" th:value="${beforeOrderQuery?.queryStartTime}"
                       class="demo-input form-control mb-2 mr-sm-2" name="queryStartTime" placeholder="请选择" size="5"/>
                <input type="date" th:value="${beforeOrderQuery?.queryEndTime}"
                       class="demo-input form-control mb-2 mr-sm-2" name="queryEndTime" placeholder="请选择" size="5"/>
                <button type="submit" class="btn btn-sm btn-gradient-primary mb-2">查询</button>
            </form>
            <div style="overflow: auto">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>
                            借款编号
                        </th>
                        <th>
                            姓名
                        </th>
                        <th>
                            申请日期
                        </th>
                        <th>
                            手机号
                        </th>
                        <th>
                            申请额度
                        </th>
                        <th>
                            还款方式
                        </th>
                        <th>
                            借款期限
                        </th>
                        <th>
                            贷款类型
                        </th>
                        <th>
                            审批金额
                        </th>
                        <th>
                            状态
                        </th>
                        <th>
                            初审
                        </th>
                        <th>
                            复审
                        </th>
                        <th style="background-color: #f2edf3">
                            操作
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="beforeOrder:${beforeOrders}">
                        <td th:text="${beforeOrder.boId}"></td>
                        <td th:text="${beforeOrder.user.userName}"></td>
                        <td th:text="${beforeOrder.oCreateTime}" style="width: 100px"></td>
                        <td th:text="${beforeOrder.user.userPhone}"></td>
                        <td th:text="${beforeOrder.oWantedMoney}"></td>
                        <td th:text="${beforeOrder.oRepayMode}"></td>
                        <td th:text="${beforeOrder.oLoanTime}"></td>
                        <td th:text="${beforeOrder.hLoanProducts.loanType}"></td>
                        <td th:if="${checkState.mType eq 2}" th:each="checkState:${beforeOrder.checkStates}"
                            th:text="${checkState.mApproveMoney}"></td>
                        <td th:text="${beforeOrder.boType}"></td>
                        <td th:text="${beforeOrder.employee.empName1}"></td>
                        <td th:text="${beforeOrder.employee.empName2}"></td>
                        <td style="background-color: #f2edf3">
                            <a style="color:orangered" class="Check" data-toggle="modal" data-target="#myModal">
                                审批
                            </a>
                            <p></p>
                            <a class="query" data-toggle="modal" data-target="#myModal1">审核信息</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<!--跳转页面-->
<div class="page-bar">
    <ul class="page-num-ul clearfix" style="list-style: none">
        <li>共<span th:text="${page.totalCount}"></span>条记录&nbsp;&nbsp; <span
                th:text="${page.pageIndex}"></span>/<span th:text="${page.totalPageCount}"></span> 页
        </li>
        <button th:onclick="'javascript:pageQry(document.forms[0],1)'" th:if="${page.pageIndex gt 1 }">首页
        </button>
        <button th:onclick="'javascript:pageQry(document.forms[0],'+${page.pageIndex - 1}+')'"
                th:if="${page.pageIndex gt 1 }">上一页
        </button>

        <button th:onclick="'javascript:pageQry(document.forms[0],'+${page.pageIndex + 1}+')'"
                th:if="${page.pageIndex lt page.totalPageCount}">下一页
        </button>
        <button th:onclick="'javascript:pageQry(document.forms[0],'+${page.totalPageCount}+')'"
                th:if="${page.pageIndex lt page.totalPageCount}">最后一页
        </button>
    </ul>
    <span class="page-go-form"><label>跳转至</label>
             <input type="hidden" id="totalPageCount" th:value="${page.totalPageCount}"/>
             <input type="text" name="inputPage" size="1" id="inputPage" class="page-key"/>页
             <button type="button" class="page-btn"
                     th:onClick="'jumpPage(document.forms[0],document.getElementById(\''+inputPage+'\').value)'">GO</button>
		</span>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
            </div>
            <h4 class="modal-title text-center" id="myModalLabel">复审审批页面</h4>
            <form id="CheckStatecheck">
                <input type="hidden" id="CheckStatecheckboId" name="boId" value="0"/>
                <input type="hidden" id="mId" name="mId" th:value="${session.sessionEmp.eId}"/>
                <div class="modal-body">
                    <div class="form-group">
                        <label for="exampleInputName3" class="text-left">复审结果：</label><br/>
                        <select name="mResult" class="form-control" id="exampleInputName3">
                            <option value="复审通过">通过</option>
                            <option value="复审驳回">驳回</option>
                            <option value="复审拒绝">拒绝</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="exampleInputName1" class="text-left">审批金额：</label><br/>
                        <input type="text" name="mApproveMoney" size="20" class="form-control" id="exampleInputName1"
                               placeholder=""/>元&nbsp;&nbsp;&nbsp;
                    </div>
                    <div class="form-group">
                        <label for="exampleInputName2" class="text-left">综合利率：</label><br/>
                        <input type="text" name="mRate" class="form-control" id="exampleInputName2"
                               placeholder=""/>%&nbsp;&nbsp;&nbsp;
                    </div>
                    <div class="form-group">
                        <label for="exampleTextarea1" class="text-left">审核意见：</label>
                        <textarea class="form-control" name="mComment" id="exampleTextarea1"
                                  rows="4"></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" id="addBtn" class="btn btn-primary" data-dismiss="modal">保存
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
            </div>
            <h4 class="modal-title text-center" id="myModalLabe2">审核信息</h4>
            <input type="hidden" id="boId" name="boId" value="0"/>
            <div class="modal-body">
                <div class="form-group">
                    <table id="checkStateTable" class="table table-bordered">
                        <thead>
                        <tr>
                            <th>审核时间</th>
                            <th>状态</th>
                            <th>审核人员</th>
                            <th>审核结果</th>
                            <th>反馈详情</th>
                        </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

</body>
<script type="text/javascript" src="../../js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/laydate/laydate.js"></script>
<script type="text/javascript" src="/layer/layer.js"></script>
<!-- plugins:js -->
<script src="/vendors/js/vendor.bundle.base.js"></script>
<script src="/vendors/js/vendor.bundle.addons.js"></script>
<!-- endinject -->
<!-- Plugin js for this page-->
<!-- End plugin js for this page-->
<!-- inject:js -->
<script src="/js/off-canvas.js"></script>
<script src="/js/misc.js"></script>
<!-- endinject -->
<!-- Custom js for this page-->
<script src="/js/dashboard.js"></script>
<!-- End custom js for this page-->
<script type="text/javascript">
    // <![CDATA[

    //01.分页查询
    function pageQry(form, pageIndex) {
        form.currentPageNo.value = pageIndex;//赋值给【分页+条件查询的表单】
        form.submit();//用js主动提交
    }

    //02.跳转页查询
    function pageQry(form, jumpPageIndex) {
        //01.数字校验
        var reg = /^[1-9]\d{0,}$/;
        if (!reg.test(parseInt(jumpPageIndex))) {
            layer.msg("请输入合法的数字", {time: 1000});
            return;
        }
        //02.范围校验：当前页不能大于总页数
        if (jumpPageIndex > document.getElementById("totalPageCount").value) {
            layer.msg("已经是最后一页!");
            return;
        }
        form.currentPageNo.value = jumpPageIndex;
        form.submit();
    }

    function dateFtt(fmt, dateStr) {
        var date = new Date(dateStr);
        var o = {
            "M+": date.getMonth() + 1,                 //月份
            "d+": date.getDate(),                    //日
            "h+": date.getHours(),                   //小时
            "m+": date.getMinutes(),                 //分
            "s+": date.getSeconds(),                 //秒
            "q+": Math.floor((date.getMonth() + 3) / 3), //季度
            "S": date.getMilliseconds()             //毫秒
        };
        if (/(y+)/.test(fmt))
            fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt))
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }

    $(function () {

        //确认审批哪一个订单
        $(".Check").click(function () {
            var boID = $(this).parent().parent().children().eq(0).html();
            $("#CheckStatecheckboId").val(boID);
        });
        //确认查看哪一个订单的信息
        $(".query").click(function () {
            var boId = $(this).parent().parent().children().eq(0).html();
            $("#boId").val(boId);
            var mId = $("#mId").val();
            $.ajax({
                url: "/xm/checkStateQuery",
                type: "get",
                data: {"boId": boId},
                dataType: "json",
                success: function (data) {
                    var checkStates = $(data.checkStates);
                    var str = "";
                    var type = "";
                    checkStates.each(function () {
                        if (this.mType == 1) {
                            type = "初审";
                        } else if (this.mType == 2) {
                            type = "复审";
                        } else if (this.mType == 3) {
                            type = "终审";
                        }
                        str += "<tr><td>" + dateFtt('yyyy-MM-dd', this.mDate) + "</td>"
                            + "<td>" + type + "</td>"
                            + "<td>" + this.empName + "</td>"
                            + "<td>" + this.mResult + "</td>"
                            + "<td>" + this.mComment + "</td>"
                            + "</tr>";
                    });
                    $("#checkStateTable").find('tbody').html(str);
                }
            });
        });
        $("#addBtn").click(function () {
            var addCheckState = $("#CheckStatecheck");
            $.ajax({
                url: "/xm/checkStateAdd2?checkState=" + addCheckState.serialize(),
                data: {"csboID": $("#CheckStatecheckboId").val()},
                type: "post",
                dataType: "JSON",
                success: function (data) {
                    if (data == true) {
                        layer.msg("审核成功", {time: 1000});
                    } else {
                        layer.msg("审核失败", {time: 1000});
                    }
                }
            })
        });
    });
    // ]]>
</script>
</html>